package org.wsff.tools.api.gateway.demo.proxy;

import org.wsff.tools.api.gateway.core.GatewayContext;
import org.wsff.tools.api.gateway.core.Proxy;
import org.wsff.tools.api.gateway.core.ProxyInvoker;
import org.wsff.tools.api.gateway.demo.Apis;
import org.wsff.tools.api.gateway.demo.model.TestRequest;
import org.wsff.tools.api.gateway.demo.model.TestResponse;
import org.wsff.tools.api.gateway.error.ProxyException;

/**
 * ExampleTestProxy
 * @author ryan
 * @version Id: ExampleTestProxy.java, v 0.1 2022-04-02 10:17 ryan Exp $$
 */
@Proxy(id = Apis.EXAMPLE_TEST)
public class ExampleTestProxy implements ProxyInvoker<TestRequest, TestResponse> {

    /**
     * 代理执行
     *
     * @param context the gateway context, include request, response, proxy name.
     * @return 业务响应 response
     * @throws ProxyException 代理异常
     */
    @Override
    public TestResponse invoke(GatewayContext<TestRequest, TestResponse> context) throws ProxyException {
        TestRequest request = context.getRequest();
        System.out.println("do invoke:" + request.getReason());
        return TestResponse.success("hello ,i am a example");
    }
}
